//
//  TsfDetailHeader.m
//  TenMinDemo
//
//  Created by Shawn Li on 2021/3/17.
//  Copyright © 2021 CYXiang. All rights reserved.
//

#import "TsfDetailHeader.h"
#import "NSString+FloatString.h"
#import <UIImageView+WebCache.h>
@interface TsfDetailHeader()
@property (weak, nonatomic) IBOutlet UIImageView *icon;
@property (weak, nonatomic) IBOutlet UILabel *info;
@property (weak, nonatomic) IBOutlet UILabel *state;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@end
@implementation TsfDetailHeader

INITFROMXIB
- (void)awakeFromNib{
    [super awakeFromNib];
    LRViewBorderRadius(self.bgView, 10, 0, LRClearColor);
}

- (void)refersh:(TsfDetailModel *)tsfDM{
    NSString *typeStr = [tsfDM.type isEqualToString:@"SEND"] ? @"-" : @"+";
    [self.icon sd_setImageWithURL:[NSURL URLWithString:tsfDM.iconUrl]];
    NSString *amountS = [NSString stringWithFormat:@"%@%@ ",typeStr,[[NSString stringWithFormat:@"%@",@(tsfDM.amount)] floatString]];
    
    NSMutableAttributedString *money = LCAttStr(amountS, [UIFont boldSystemFontOfSize:20], [UIColor whiteColor]);
    [money appendAttributedString:LCAttStr(tsfDM.assetSymbol, [UIFont boldSystemFontOfSize:12], [UIColor whiteColor])];
    
    self.info.attributedText = money;
    NSString *state = [tsfDM.status isEqualToString:@"Success"] ? @"已完成" : [tsfDM.status isEqualToString:@"Faild"] ? @"失败" : @"确认中";
    self.state.text = state;
    UIColor *sColor = [tsfDM.status isEqualToString:@"Success"] ? LRRGBColor(147, 91, 255) : [tsfDM.status isEqualToString:@"Faild"] ? LRRGBColor(255, 149, 117) : LRRGBColor(255, 216, 105);
    
    self.state.textColor = sColor;
}

@end
